package com.itheima.algorithm.recursion_single;

/**
 * 递归反向打印字符串
 */
public class E02ReversePrintString {

    public static void f(int n, String str) {
        if (n == str.length()) {
            return;
        }
        f(n + 1, str);
        System.out.println(str.charAt(n)); //归
    }

    public static void fn(String str) {
        int length = str.length();
        if (length >= 1) {
            System.out.println(str.charAt(length - 1));
            length--;
            fn(str.substring(0, length));
        }
    }

    public static void main(String[] args) {
        fn(0, "1234567");
        fn("1234567");
    }

    public static void fn(int n, String str) {
        if (n == str.length()) {
            return;
        }
        fn(n + 1, str);
        System.out.println(str.charAt(n)); //归
    }


}
